/**
 * Description: Controller测试类基类
 * Copyright:Copyright 2015 nfky.com. All rights reserved
 * @author:kai
 * @since:1.0.0
 * Create at:2015年10月21日 上午11:06:57
 *  
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2015年10月21日   kai       1.0.0     Initial
 */
package com.metro.core;

import org.mockito.MockitoAnnotations;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.testng.annotations.BeforeClass;


/**
 * 
 * Controller测试类基类 <br>
 * <p>继承此类以后，测试类默认是回滚的如果某一个测试方法不需要回滚，请加入 {@link Rollback(false)}注解即可
 * <p>测试类默认读取的spring配置文件为classpath根路径下的test-applicationContext.xml, spring-servlet.xml文件，
 * 如果测试过程中需要屏蔽部分配置文件请直接修改test-applicationContext.xml
 * @author kai
 * @since [1.0.0]
 * @version [1.0.0, 2015年10月21日]
 */
@ContextConfiguration(locations ={"classpath:test-applicationContext.xml", "classpath:spring-servlet.xml"})
@Rollback
public abstract class BaseControllerTestNG extends AbstractTestNGSpringContextTests{
	protected MockMvc mockMvc;

    protected MockHttpServletRequestBuilder request;
    protected MockHttpServletResponse response;
    
	protected Logger log = LoggerFactory.getLogger("TEST");
	

    public abstract Object[] getControllers();
    
    @BeforeClass
    public void setup() {
        MockitoAnnotations.initMocks(this);
        this.mockMvc = MockMvcBuilders.standaloneSetup(getControllers()).build();
    }
}
